var MongoClient= require('mongodb').MongoClient

var url= 'mongodb://127.0.0.1:27017'
var dbName= 'project'

function connect(callback){
	MongoClient.connect(url,function(err,client){
		if(err){
			console.log('数据库连接错误', err)
		}else{
			var db= client.db(dbName)
			callback && callback(db)
			db.collection("users").find().toArray(function(err, docs){
				console.log('用户列表',docs)
				
			})
			client.close()
		}
	})
}

module.exports = {
	connect
}